import React,{useState,useCallback,useEffect} from 'react';

export default function HookHotWinResize(){
    const [size, setSize] = useState({
        width: window.documentElement.clientWidth,
        height: window.documentElement.clientHeight
    });

    const onResize = useCallback(()=>{
        setSize({
            width: window.documentElement.clientWidth,
            height: window.documentElement.clientHeight
        })
    },[])

    useEffect(()=>{
        window.addEventListener('resize',onResize);
        return ()=>{
            window.removeEventListener('resize',onResize)
        }
    },[])

    return size;
}